<template>
  <div class="info">
    <h3>代码审查设置</h3>
    <el-divider />
    <div class="box-card">
      <p style="width: 800px">
        本功能用于设置 Pull Request 默认审查人员与合并规则
      </p>
      <p style="height: 10px"></p>
      <p style="width: 800px">
        指派人员将作为Pull Request 创建时的预设指派，且不允许 Pull
        Request创建者修改，如未设置，则允许创建者自行指派。该设置项不会影响已创建指派的Pull
        Request
      </p>
    </div>

    <h5>指派审查人员</h5>
    <el-select
      v-model="value1"
      multiple
      size="large"
      placeholder="请选择"
      style="width: 600px; margin-right: 16px; vertical-align: middle"
    >
      <el-option
        v-for="item in users"
        :key="item"
        :label="item"
        :value="item"
      />
    </el-select>

    <div style="margin-bottom: 30px">
      <p class="inlineBlock">至少需要</p>
      <el-input-number
        v-model="reviewNum"
        :min="0"
        :max="10"
        @change="handleChange"
        controls-position="right"
        style="width: 80px"
      />
      <p class="inlineBlock">名审查人员审查通过后可合并</p>
    </div>

    <el-form-item>
      <el-button type="primary" @click="submit">保存</el-button>
    </el-form-item>
  </div>
</template>

<script>
import { ElMessage } from "element-plus";
import request from "@/utils/request";
export default {
  data() {
    return {
      rules: {
        name: [{ required: true, message: "请输入仓库名称", trigger: "blur" }],
      },

      reviewNum: 2,
      value1: ["我", "徐"],
      users: ["我", "李", "徐", "毛"],
    };
  },
  mounted() {
    request
      .get(
        `housesetting-review?ownnername=${this.$route.params.username}&housename=${this.$route.params.housename}`
      )
      .then((res) => {
        console.log(res);
        this.users = res.data.data;
        this.reviewNum = res.message;
      });
  },
  methods: {
    submit() {
      if (this.value1 == "") {
        ElMessage("请选择人员");
      } else {
        request
          .post(
            `${this.$route.params.username}/${this.$route.params.housename}/housesetting-review`,
            {
              reviewNum: this.reviewNum,
              value1: this.value1,
            }
          )
          .then((res) => {
            if (res.code == 200) {
              ElMessage("成功");
            } else {
              ElMessage("失败");
            }
          });
      }
    },
  },
};
</script>



<style>
.info {
  display: inline-block;
  position: absolute;
  margin-top: 3%;
  margin-left: 5%;
}
.box-card {
  padding: 1em 1.5em;
  position: relative;
  font-size: 0.8em;
  border-radius: 4px;
  border: 1px solid #e3e9ed;
  background: #573a08;
  background-color: #fffaf3;
  box-shadow: 0px 0px 0px 1px #c9ba9b inset, 0px 0px 0px 0px rgba(0, 0, 0, 0);
  margin-top: 0px;
  display: block;
  color: #573a08;
  margin-bottom: 15px;
}
.inlineBlock {
  display: inline-block;
}
</style>